<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <!--    <link href="/static/css/dialog.css" rel="stylesheet"/>-->
    <!--    <script src="/static/js/dialog.js"></script>-->
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>



    <!--开关主键-->
    <script src="/static/bootstrap/bootstrap-switch.js"></script>
    <link href="/static/bootstrap/bootstrap-switch.css" rel="stylesheet"/>

    <!-- PNotify -->
    <script type="text/javascript" src="/static/pnotify/pnotify.js"></script>
    <link href="/static/pnotify/pnotify.css" rel="stylesheet" type="text/css"/>
    <link href="/static/pnotify/pnotify.brighttheme.css" rel="stylesheet" type="text/css"/>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}
</head>
<body>
<style>
    .modal-body{background-color:#fff!important;}
    .form-horizontal .control-label{display: inline-block;width:7%;
        text-align:justify!important;
        text-align-last:justify;/*解决IE的支持*/ }
</style>
<!--<div class="modal-header">-->
<!--&lt;!&ndash;    <button type="button" class="close" data-dismiss="modal" close="true">&ndash;&gt;-->
<!--&lt;!&ndash;        <span aria-hidden="true">×</span>&ndash;&gt;-->
<!--&lt;!&ndash;    </button>&ndash;&gt;-->
<!--    <h4 class="modal-title">-->
<!--        <span class="fa fa-legal"></span>&nbsp;平台配置-->
<!--    </h4>-->
<!--</div>-->


<div class="config_content newtest">

    <div class="container new_serach">
        {volist name="powerList" id="vo"}
        <a class="btn btn-primary btn-sm" href="{$vo['url']}">{$vo.name}</a>
        {/volist}
    </div>

    <div class="modal-body">
        <form class="form-horizontal layui-form">


            <div class="form-group">
                <label class="col-sm-2 control-label">标题</label>
                <div class="col-sm-4">
                    <input class="form-control" name="title" placeholder="标题" value="{$config.title}">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label">关键字</label>
                <div class="col-sm-4">
                    <input class="form-control" name="keywords" placeholder="关键字" value="{$config.keywords}">
                </div>
            </div>



            <div class="form-group">
                <label class="col-sm-2 control-label">平台名称</label>
                <div class="col-sm-4">
                    <input class="form-control" name="name" placeholder="平台名称" value="{$config.name}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">socket服务地址</label>
                <div class="col-sm-4">
                    <input class="form-control" name="socket" placeholder="socket服务地址" value="{$config.socket}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">描述</label>
                <div class="col-sm-4">
                    <textarea class="form-control ng-binding" name="description">{$config.description}</textarea>
                </div>
            </div>

            <div class="form-group js_photos">
                <label class="col-sm-2 control-label"> logo</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="file" name="" class="do_upload" data-val="idCard_handheld"  style="display: none">
                        <input type="text" class="form-control idCard_handheld"  disabled="" value="{$config.logo}">
                        <input type="hidden" class="form-control idCard_handheld" name="logo" value="{$config.logo}" >
                        <span class="group-span-filestyle input-group-btn" tabindex="0">
                            <label class="btn btn-default id_photos" data-original-title="" title="">
                                <span class="glyphicon glyphicon-folder-open"></span>
                                上传
                            </label>
                        </span>
                        </span>
                    </div>
                    <img class="config_img idCard_handheld" src="{$config.logo}" >
                </div>
            </div>

        </form>
    </div>
    <div class="modal-footer">
<!--        <button type="button" class="layui-btn layui-btn-primary" >取消</button>-->
        <button type="button" class="layui-btn js_btn" >保存</button>
    </div>
</div>


<script>

    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");
        var index = layer.msg('正在提交中....');

        $.ajax({
            url: "{:URL('common/upload/ad_upload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                $("."+content).find("img").attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })

    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;



        $(".js_btn").click(function () {
           var data = $("form").serialize();
            $.ajax({
                type: "post",
                url: "{:URL('admin/system/platform')}",
                data: data,
                dataType: "json",
                success: function(data){
                    layer.alert(data.msg);
                    if(data.code==0){
                        window.location.reload();
                    }
                }
            });
           console.log(data);
        });

    });

    var newModal = new yii.modal();
    //添加页面
    $(".js_upload").click(function () {
        $(newModal.getid()).show();
        var type = $(this).attr("data-type");
        newModal.initialization({
            url: "{:URL('home/Upload/index')}",
            type: "post",
            data:{
                type:'detail',
                multiple:type
            }
        });
    });

    //头像
    newModal.on("logo",function(data){
        var images = '';
        $(newModal.getid()).find("#data-area .newimages .active img").each(function () {
            images = $(this).attr('src');
            return false
        })
        //$(newModal.getid()).hide();
        $("#logo").val(images);
    });


    $(this).find('.modal-dialog').css({
        'width': '800px'
    });

</script>
</body>
</html>
